package org.rssReader.model;

import java.io.FileInputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

import org.apache.log4j.Logger;

public class Model {
	private List<String> showsList;
	private List<String> regexes;
	private Properties prop;
	
	public static Model model;
	private static final Logger logger = Logger.getLogger(Model.class);
	
	private Model(){
		showsList = new ArrayList<String>();
		regexes = new ArrayList<String>();
		prop = new Properties();
		try {
			prop.load(new FileInputStream("src\\org\\rssReader\\model\\servers.properties"));
		} catch (Exception e) {
			logger.error("error in Model constructor", e);
		}
	}
	
	public static Model getInstance(){
		if(model == null){
			model = new Model();
		}
		return model;
	}
	
	public void AddShow(String show){
		showsList.add(show);
	}
	
	public void AddServer(String server){
		regexes.add(prop.getProperty(server));
	}
	
	public String getShow(int index){
		return showsList.get(index);
	}
	

	public List<String> getRegexes() {
		return regexes;
	}

	public void setRegexes(List<String> regexes) {
		this.regexes = regexes;
	}

	public List<String> getShowsList() {
		return showsList;
	}

	public void setShowsList(List<String> showsList) {
		this.showsList = showsList;
	}
}
